package com.tyae.bean;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
public class ProcessoFase implements Serializable{

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue (strategy = GenerationType.AUTO)
	private int codigoProcessoFase;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "codigoProcesso", insertable = true, updatable = true)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private Processo processo;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "codigoFase", insertable = true, updatable = true)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private Fase fase;
	
	@Temporal(TemporalType.DATE)
	private Date data;
	
	@Column(length=5)
	private String hora;
	
	
	public ProcessoFase(){
		
	}


	public Processo getProcesso() {
		return processo;
	}


	public void setProcesso(Processo processo) {
		this.processo = processo;
	}


	public Fase getFase() {
		return fase;
	}


	public void setFase(Fase fase) {
		this.fase = fase;
	}


	public Date getData() {
		return data;
	}


	public void setData(Date data) {
		this.data = data;
	}


	public String getHora() {
		return hora;
	}


	public int getCodigoProcessoFase() {
		return codigoProcessoFase;
	}


	public void setCodigoProcessoFase(int codigoProcessoFase) {
		this.codigoProcessoFase = codigoProcessoFase;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + codigoProcessoFase;
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ProcessoFase other = (ProcessoFase) obj;
		if (codigoProcessoFase != other.codigoProcessoFase)
			return false;
		return true;
	}


	public void setHora(String hora) {
		this.hora = hora;
	}
	

}
